package main

import (
	"context"

	"google.golang.org/grpc/metadata"
)

// 返回 metadata 中的 "Player-Uuid".
// 没有则返回 "", false
func getPlayerUUID(ctx context.Context) (string, bool) {
	md, ok := metadata.FromIncomingContext(ctx)
	if !ok {
		return "", false
	}

	uuids, ok := md["player-uuid"] // 自动转小写
	if !ok {
		return "", false
	}

	if len(uuids) == 0 {
		return "", false
	}

	return uuids[0], true
}
